package J1128;

public class Main {
    //将两个有序链表合并成一个有序链表
    public MySingleList.ListNode nn(MySingleList.ListNode l1, MySingleList.ListNode l2) {
        MySingleList.ListNode newHead = new MySingleList.ListNode(-1);
        MySingleList.ListNode headA = l1;
        MySingleList.ListNode headB = l2;
        MySingleList.ListNode cur = newHead;
        while(headA != null && headB != null) {
            if(headA.val < headB.val) {
                cur.next = headA;
                headA = headA.next;
                cur = cur.next;
            } else {
                cur.next = headB;
                headB = headB.next;
                cur = cur.next;
            }
        }
        if(headA != null) {
            cur.next = headA;
        }
        if(headB != null) {
            cur.next = headB;
        }
        newHead = newHead.next;
        return newHead;
    }
    ////判断两个链表是否相交 测试例子
    public void craetcut(MySingleList.ListNode A, MySingleList.ListNode B) {
        B.next = A.next.next;
        //把B和A第二个后面的相连
    }
}
